<?php include_component('questionaire', 'tabs') ?>
<div class="sf_admin_form">
    <table style="float:left">
        <tr>
            <td>
                <fieldset>
                    <legend class="formLabel"><?php echo __('Results') ?></legend>
                    <table>
                        <?php foreach ($results as $result): ?>
                            <tr>
                                <td><?php echo $result->getResultUser()->getFirstName()
                        . ' ' . $result->getResultUser()->getLastName() ?> <?php if($result->getResultUser()->getRemoteAddr()): ?>( <i><?php echo $result->getResultUser()->getRemoteAddr() ?></i> )<?php endif ?></td>
                                <td style="width:50px;"></td>
                                <?php if ($selResult && $selResult->getId() == $result->getId()): ?>
                                    <td>
                                        <fieldset>
                                            <legend class="formLabel"><?php echo $result->getResultUser()->getFirstName().' '.$result->getResultUser()->getLastName().' '.__('results') ?></legend>
                                            <table>
                                            <?php foreach ($result->getAnswers() as $i => $answer): ?>
                                                <tr>
                                                    <td><?php echo ($i+1)."." ?></td>
                                                    <td><?php echo $answer->getQuestion() ?></td>
                                                    <td>&nbsp;</td>
                                                    <td><?php echo $answer->getAnswer() ?></td>
                                                </tr>
                                            <?php endforeach; ?>
                                            </table>
                                        </fieldset>
                                    </td>
                                <?php else: ?>
                                    <td><input id="<?php echo $result->getId() ?>" class="formSubmit check_results" 
                                               type="submit" name="check" value="<?php echo __('Check results') ?>" /></td>
                                    <?php endif; ?>
                            </tr>
                            <tr><td></td></tr>
                        <?php endforeach; ?>
                    </table>
                </fieldset>
            </td>
        </tr>
    </table>
</div>

<?php //include_component('questionaire', 'footerTabs') ?>

<script type="text/javascript">
    $('.check_results').click(function() {
        window.location.href = '<?php echo url_for('@admin_page?module=questionaire&action=results&id=' . $qId . '&result_id=') ?>' + $(this).attr('id');
            
        return false;
    });
</script>